home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
SAT 2.3.8
/
Demos
/
FastLoad Demo ƒ
/
FastLoadDemo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-23
|
2KB
|
81 lines
/* C translation from Pascal source file: FastLoadDemo.p */
//• main FastLoadDemo;
/*A demo/test program showing how to load a large number of faces from PICT resources with*/
/*minimal overhead. There are some parts missing - row start tables to be precise - and you*/
/*could possibly take the mask regions out. It all depends on your needs. If you plan to use SAT's*/
/*blitters all the time (i.e. SATRun(true) you can remove the regions.*/
/*This program will ONLY work in 256 colors or more! In B/W or 4-bit color, there are additional*/
/*data needed since SAT does certain special optimizing for those depths. I have tested it in 256*/
/*and thousands of colors, and it will probably run out of memory in millions.*/
/*This program does no error checking! You will have to add that to use it in a real program!*/
/*/Ingemar Ragnemalm december 1995*/
/*Revised may 1996, in order to clean up, add more options, and make FaceLoad a stand-alone*/
/*reusable module.*/
/* C version by Ingemar june -96 */
/* Note: if you make a PPC project out of this, use 68k struct alignment. */
#include "SAT.h"
#include "FastLoad.h"
pascal void Nop(SpritePtr me);
pascal void Nop(SpritePtr me){}
void main(void)
{
struct Sprite ppsprite;
SpritePtr sptr;
FacePtr faces;
short h, v;
SATInitToolbox();
SATInit(128, 128, 400, 300);
/*Load the faces!*/
SysBeep(1);
faces = Load2DFaceArray(129, 130, 100, 32, 32, 10, true, true);
SysBeep(1);
/*I use SATNewSpritePP here. That has no connection to the face loading - I could just as well*/
/*use SATNewSprite as usual! Consider this a little demonstration of SATNewSpritePP thrown in*/
/*"for free".*/
sptr = SATNewSpritePP(nil, (char *)&ppsprite, 0, 0, 0, nil);
ppsprite.task = &Nop;
ppsprite.face = nil;
ppsprite.face = SATGetFace(128);
SATSetPortScreen();
HideCursor();
while ( ! Button () )
{
/*Set the face of the sprite to one of the 100 sprites in the faces array, depending on mouse position.*/
GetMouse(&ppsprite.position);
h = ppsprite.position.h * 10 / gSAT.offSizeH;
if ( h < 0 )
h = 0;
if ( h > 9 )
h = 9;
v = ppsprite.position.v * 10 / gSAT.offSizeV;
if ( v < 0 )
v = 0;
if ( v > 9 )
v = 9;
ppsprite.face = &faces[h + v * 10];
SATRun(false);
};
ShowCursor ();
}